#!/usr/bin/env python

hexas = []
for lin in open('hexabits.txt').readlines():
    lin = lin.split()
    hexaNum = int(lin[0])
    bits = []
    for i in range(1,7):
        if lin[i] == '7': bits.append(1)
        elif lin[i] == '8': bits.append(0)
    hexas.append( (hexaNum,	bits) )
	
hexnums = []    
for num, bits in hexas:
    val = reduce(lambda x,y:2*x+y, bits)
    print '%2d %s %2d' % (num, bits, val)
    hexnums.append( (val, num) )
    
hexnums.sort()

print ','.join(['%2d'%n for v,n in hexnums])
    
		